import { axios } from '@/utils/request'
/**
 * 用户模块api接口
*/

// 根据用户id获取用户信息
function getUserInfo(data){
  return axios({
    url: '/user-service/user/info',
    method: 'get',
    params: data
  })
}
// 添加用户
function addUser (data) {
  return axios({
    url: '/user-service/user',
    method: 'post',
    data
  })
}

// 编辑用户
function editUser (data) {
  return axios({
    url: '/user-service/user',
    method: 'put',
    data
  })
}

// 删除用户
function deleteUser (data) {
  return axios({
    url: '/user-service/user',
    method: 'delete',
    data
  })
}

// 重置用户密码
function resetUserPwd (data) {
  return axios({
    url: '/user-service/user/pwd/reset',
    method: 'put',
    data
  })
}
// 解除冻结
function relieveLock (data) {
  return axios({
    url: '/user-service/user/unlock',
    method: 'put',
    data
  })
}
// 获取用户分页数据
function getUserPageData (query) {
  console.log(query, 'query')
  return axios({
    url: '/user-service/user/list',
    method: 'get',
    params: query
  })
}
// 问题反馈
function getQuestionPageData (parameter) {
  return axios({
    url: '/user-service/question/list',
    method: 'get',
    params: parameter
  })
}
// 获取用户下拉框
function getUserSelect (query) {
  return axios({
    url: '/user-service/user/select',
    method: 'get',
    params: query
  })
}

// 停用与启用用户
function enableUser (data) {
  return axios({
    url: '/user-service/user/enable',
    method: 'put',
    data
  })
}

// 修改自己的密码
function modifyLoginUserPwd (data) {
  return axios({
    url: '/user-service/user/pwd/current',
    method: 'put',
    data
  })
}
// 修改用户部分信息(用户名|邮箱|备注)
function modifyUserPartInfo (path, data) {
  return axios({
    url: '/user-service' + path,
    method: 'put',
    data
  })
}

// 关联车型
function setUserModel (data) {
  return axios({
    url: '/user-service/user/model',
    method: 'post',
    data
  })
}


// 邮件推送编辑
function editEmailPush (data) {
  return axios({
    url: '/user-service/emailPush/edit',
    method: 'post',
    data
  })
}


// 获取邮件推送
function getEmailPush () {
  return axios({
    url: '/user-service/emailPush/getEmailPush',
    method: 'get'
  })
}

// 根据账号获取用户邮件推送配置
function getEmailPushByAccount (query) {
  return axios({
    url: '/user-service/emailPush/getEmailPushByAccount',
    method: 'get',
    params: query
  })
}

export default {
  getUserInfo,
  getUserPageData,
  addUser,
  editUser,
  deleteUser,
  resetUserPwd,
  relieveLock,
  getUserSelect,
  enableUser,
  modifyLoginUserPwd,
  modifyUserPartInfo,
  setUserModel,
  editEmailPush,
  getEmailPush,
  getEmailPushByAccount,
  getQuestionPageData
}
